//
//  CLReadViewStatusTopView.m
//  CLBrowser
//
//  Created by 梁慧聪 on 2022/8/11.
//

#import "CLReadViewStatusTopView.h"

@implementation CLReadViewStatusTopView


- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubviews];
    }
    return self;
}

- (void)addSubviews {
    
    // 书名
    UILabel *bookName = [[UILabel alloc]init];
    self.bookName = bookName;
    bookName.font = CL_FONT_SA_10;
    bookName.textColor = [CLReadConfigure sharedInstance].statusTextColor;
    bookName.textAlignment = NSTextAlignmentLeft;
    [self addSubview:bookName];
    
    // 章节名
    UILabel *chapterName = [[UILabel alloc]init];
    self.chapterName = chapterName;
    chapterName.font = CL_FONT_SA_10;
    chapterName.textColor = [CLReadConfigure sharedInstance].statusTextColor;
    chapterName.textAlignment = NSTextAlignmentRight;
    [self addSubview:chapterName];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    CGFloat w = self.frame.size.width;
    CGFloat h = self.frame.size.height;
    CGFloat labelW = (w - CL_SPACE_SA_15) / 2;
    
    // 书名
    self.bookName.frame = CGRectMake(0, 0, labelW, h);
    
    // 章节名
    self.chapterName.frame = CGRectMake(w - labelW, 0, labelW, h);
}

@end
